package com.huawei.esdk.tp.northcommu.cxf.professional.convert;

import java.util.ArrayList;
import java.util.List;

import org.apache.cxf.common.util.CollectionUtils;

import com.huawei.esdk.platform.common.exception.SDKException;
import com.huawei.esdk.tp.common.ErrInfo;
import com.huawei.esdk.tp.domain.model.bean.SiteVolume;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.SiteVolumeEx;

public class TPProfessionalConfCtrlConvert
{
    //    public QueryHistoryRecordAddrExResponse queryHistoryRecordAddrExModel2Soap(SDKResult<RecordingConference> result)
    //    {
    //        QueryHistoryRecordAddrExResponse response = new QueryHistoryRecordAddrExResponse();
    //        response.setResultCode((int)result.getErrCode());
    //        
    //        if (null != result.getResult() && !CollectionUtils.isEmpty(result.getResult().getRecordAddrs()))
    //        {
    //            ConfRecordAddrEx confRecordAddrEx = null;
    //            for (ConfRecordAddr addr : result.getResult().getRecordAddrs())
    //            {
    //                confRecordAddrEx = new ConfRecordAddrEx();
    //                confRecordAddrEx.setConfId(addr.getConfId());
    //                confRecordAddrEx.setRecordAddr(addr.getRecordAddr());
    //                response.getRecordAddrs().add(confRecordAddrEx);
    //            }
    //        }
    //        
    //        return response;
    //    }
    
    public List<SiteVolume> siteVolumeExSoap2Model(List<SiteVolumeEx> siteVolumeExs) throws SDKException
    {
        List<SiteVolume> siteVolumes = new ArrayList<SiteVolume>();
        if (CollectionUtils.isEmpty(siteVolumeExs))
        {
            return siteVolumes;
        }
        for (SiteVolumeEx siteVolumeEx : siteVolumeExs)
        {
            if (null != siteVolumeEx)
            {
                siteVolumes.add(siteVolumeExSoap2Model(siteVolumeEx));
            }
        }
        return siteVolumes;
    }
    
    public SiteVolume siteVolumeExSoap2Model(SiteVolumeEx siteVolumeEx) throws SDKException
    {
        SiteVolume siteVolume = new SiteVolume();
        if(null == siteVolumeEx.getSiteUri() || 
            null == siteVolumeEx.getVolume())
        {
            SDKException sdkException = new SDKException(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORDESC);
            sdkException.setSdkErrCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
            throw sdkException;
        }
        siteVolume.setSiteUri(siteVolumeEx.getSiteUri());
        siteVolume.setVolume(siteVolumeEx.getVolume());
        return siteVolume;
    }
}
